<?php

declare(strict_types=1);

/**
 * @Author:     Frank
 * @contact     frank_hhm@163.com
 * @Date:       2023-01-07 21:14:53
 * @Last Modified time: 2023-01-09 16:27:11
 */

namespace app\common\model\store;

use frank\base\BaseModel;
use frank\traits\ModelTrait;
use app\common\enum\EnumFactory;

/**
 * 商城-自定义页面
 * Class DiyPageModel
 * @package app\common\model\store
 */
class DiyPageModel extends BaseModel
{
    use ModelTrait;

    /**
     * 数据表主键
     */
    protected $pk = 'id';

    /**
     * 模型名称
     */
    protected $name = 'store_diy_page';

	protected $json = ['page_data'];

    /**
     * id搜索器
     */
    public function searchIdAttr($query, $value)
    {
        if (is_array($value)) {
            $query->whereIn('id', $value);
        } else {
            $query->where('id', $value);
        }
    }

    /**
     * 首页搜索器
     */
    public function searchIsHomeAttr($query, $value)
    {
        if(empty($value))  return $query;
        $query->where('is_home', $value);
    }
}